package com.raymond.queue.client.service;

import com.raymond.queue.common.msg.BaseMessage;
import com.raymond.queue.common.msg.response.ConsumptionMsgResponse;

import java.util.concurrent.atomic.AtomicInteger;

/**
 * 生产回调处理
 *
 * @author :  raymond
 * @version :  V1.0
 * @date :  2021-07-14 11:39
 */
public class ConsumptionCallBack implements Callback {
    AtomicInteger atomicInteger = new AtomicInteger();
    @Override
    public void callback(BaseMessage req, BaseMessage resp) {
        ConsumptionMsgResponse resp1 = (ConsumptionMsgResponse) resp;
//        atomicInteger.getAndIncrement();
        atomicInteger.addAndGet(resp1.getData().size());
    }

    @Override
    public void sendFailCallback(BaseMessage req, int code) {
//        atomicInteger.getAndIncrement();
    }

    public int get() {
        return atomicInteger.get();
    }
}
